package win.demonlegion.controller;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import win.demonlegion.eshimin.config.EshiminConfig;
import win.demonlegion.eshimin.response.UserInfoThirdResponse;
import win.demonlegion.eshimin.service.EshiminService;

@Slf4j
@RestController
@RequestMapping("eshimin")
public class EshiminController {
    @Autowired
    private EshiminService eshiminService;
    @Autowired
    private EshiminConfig eshiminConfig;

    @GetMapping("basic")
    public String userBasic(String userName, String accessToken) {
        return JSON.toJSONString(eshiminService.userBasic(userName, accessToken));
    }

    @GetMapping("identity")
    public String userIdentity(String userName, String accessToken) {
        return JSON.toJSONString(eshiminService.userIdentity(userName, accessToken));
    }

    @GetMapping("info")
    public String userInfo(String accessToken) {
        UserInfoThirdResponse response = eshiminService.userInfoThird(accessToken);
        log.info("response: {}", response.toString());
        return response.toString();
    }

    @GetMapping("config")
    public String config() {
        return eshiminConfig.toString();
    }
}
